package com.charmzenus.smallshop.base;

import com.charmzenus.smallshop.controller.IndexController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class AppControllerActive {

    private static final Logger logger = LoggerFactory.getLogger(IndexController.class);

    @ResponseBody
    @ExceptionHandler(value = Exception.class)
    public ErrorInfo<String> errorHandler(Exception s) {
        logger.error(s.getMessage());
        return new ErrorInfo<String>("服务器异常");
    }
}
